/*
    云备份日志打印模块 -- debug info等级日志打印标准输出 warn error fatal 等级打印到日志文件
*/
#ifndef __M_CLOG_H__
#define __M_CLOG_H__
#include"../tools/logs/log.h"

namespace Hxy_Cloud
{
    class CloudLog
    {
        private:
        std::string _name;
        CloudLog()
        {
            std::unique_ptr<Hxy_Log::LoggerBuilder> logger(new Hxy_Log::GlobalLoggerBuilder());
            logger->BuildLoggerName("sync");
            logger->BuildLoggerValue(Hxy_Log::LogLevel::value::INFO);
            logger->BuildLoggerType(Hxy_Log::LoggerType::SYNCTYPE);
            logger->BuildFormatter();
            logger->BuildSink<Hxy_Log::FileSink>("./cloud.log");
            logger->BuildSink<Hxy_Log::StdOutSink>();
            logger->build();
            _name = "sync";
        }
        public:
        void Debug(const std::string& filename,size_t line,const std::string& fmt,...)
        {
            DEBUG(filename,line,fmt);
        }
        void Info(const std::string& filename,size_t line,const std::string& fmt,...)
        {
            INFO(filename,line,fmt);
        }
        void Warn(const std::string& filename,size_t line,const std::string& fmt,...)
        {
            Hxy_Log::getLogger(_name)->warn(filename,line,fmt);
        }
        void Error(const std::string& filename,size_t line,const std::string& fmt,...)
        {
            Hxy_Log::getLogger(_name)->error(filename,line,fmt);
        }
        void Fatal(const std::string& filename,size_t line,const std::string& fmt,...)
        {
            Hxy_Log::getLogger(_name)->fatal(filename,line,fmt);
        }
        public:
        static CloudLog& GetInstance()
        {
            static CloudLog log;
            return log;
        }
    };
}

#endif